package com.woniuxy.ServletContext;

import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.Properties;

/**
 * @auther linke
 * @create 2021-10-19 14:35
 */
@WebServlet("/servletContextDemo07")
public class ServletContextDemo07 extends HttpServlet {
    /**
     * 获取核心配置文件参数
     * @param req
     * @param resp
     * @throws ServletException
     * @throws IOException
     */
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {

        System.out.println("servletContextDemo07...执行了");

        //获取servletcontext对象 根据标签名获取值
        String name = req.getServletContext().getInitParameter("name");
        System.out.println(name);//tom


    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        this.doGet(req, resp);
    }
}
